package org.yjc.service;

import java.util.List;
import java.util.Optional;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.stereotype.Service;
import org.yjc.entity.College;
import org.yjc.repository.CollegeRepository;

@Service
public class CollegeService {
	@Autowired
	private CollegeRepository collegeDAO;

	public Page<College> findAll(Specification<College> spec, Pageable pageable) {
		return collegeDAO.findAll(spec, pageable);
	}

	public void save(College college) {
		collegeDAO.save(college);
	}

	public void deleteById(Integer ids1) {
		collegeDAO.deleteById(ids1);
		
	}

	public College findById(Integer id) {
		Optional<College> optional = collegeDAO.findById(id);
		if(optional.isPresent()) {
			return optional.get();
		}
		return null;
		
		
	}

	public List<College> findAll() {
		return collegeDAO.findAll();
	}
}
